{extend name="public/base" /}

{block name="title"}<title>{if condition="$data"}{$Think.lang.edit}{else /}{$Think.lang.create}{/if}</title>{/block}

{block name="pjax_container"}
<div class="hry-content-wrapper">
<section class="content-header">
    <ol class="breadcrumb">
		<li>合同管理</li>
		<li class="active">合同信息</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <form class="form-horizontal" method="POST" action="" onsubmit="return false" >
                <input type="hidden" name="id" value="{$data.id}" />
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_base" data-toggle="tab">{$Think.lang.base_param}</a></li>
                        
                        {if condition=" $mods == 'addonvideo' "}
                        <li><a href="#tab_video" data-toggle="tab">{$Think.lang.video_param}</a></li>
                        {elseif condition=" $mods == 'addonalbum' "/}
                        <li><a href="#tab_album" data-toggle="tab">{$Think.lang.album_param}</a></li>
                        {else /}
                        {/if}
                        
                        <li><a href="#tab_advanced" data-toggle="tab">{$Think.lang.advanced_param}</a></li>
                        <li class="pull-right"><a href="javascript:history.back(-1)" class="btn btn-sm" style="padding:10px 2px;"><i class="fa fa-list"></i> {$Think.lang.back}</a></li>
                    </ul>
                    <div class="tab-content">
					
						<div class="tab-pane active" id="tab_base">
							<div class="form-group">
								<label class="col-sm-2 control-label">合同名称</label>
								<div class="col-sm-7"><input class="form-control" name="title" value="{$data.title}" {if $data.fid}disabled{/if} placeholder="合同名称"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">合同页码</label>
								<div class="col-sm-7"><input class="form-control" name="fpages" value="{$data.fpages}" {if $data.fid}disabled{/if} placeholder="合同页码"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">所属项目</label>
								<div class="col-sm-7">
									<select class="form-control" name="project_id" style="width:100%;">
										{volist name="ProjectList" id="vo"}
										<option value="{$vo.id}" {if condition="$data.project_id eq $vo.id"}selected="selected"{/if} >{$vo.project_name}</option>
										{/volist}
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">合同文件</label>
								<div class="col-sm-7">
								<input class="form-control" type="file" id="file" {if $data.fid}disabled{/if} />
								<input type="hidden" name="file_base64" id="file_base64" value="" />
								<input type="hidden" name="file_md5" id="file_md5" value="" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">截止时间</label>
								<div class="col-sm-7">
									<div class="input-group">
										<input class="form-control timepicker" name="expiretime" value="{$data.expiretime}" placeholder="截止时间" >
										<div class="input-group-addon"><i class="fa fa-clock-o"></i></div>
									</div>
								</div>
							</div>
						</div>
						
                        <div class="tab-pane" id="tab_advanced">
							<div class="form-group">
								<label class="col-sm-2 control-label">钱的页码</label>
								<div class="col-sm-7"><input class="form-control" name="mpage" value="{$data.mpage}" placeholder="钱的页码"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">钱坐标-X</label>
								<div class="col-sm-7"><input class="form-control" name="xmoney" value="{$data.xmoney}" placeholder="钱坐标-X"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">钱坐标-Y</label>
								<div class="col-sm-7"><input class="form-control" name="ymoney" value="{$data.ymoney}" placeholder="钱坐标-X"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">大写页码</label>
								<div class="col-sm-7"><input class="form-control" name="hz_page" value="{$data.hz_page}" placeholder="大写页码"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">大写-X</label>
								<div class="col-sm-7"><input class="form-control" name="hz_x" value="{$data.hz_x}" placeholder="大写-X"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">大写-Y</label>
								<div class="col-sm-7"><input class="form-control" name="hz_y" value="{$data.hz_y}" placeholder="大写-Y"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">姓名页码</label>
								<div class="col-sm-7"><input class="form-control" name="npage" value="{$data.npage}" placeholder="姓名页码"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">姓名-X</label>
								<div class="col-sm-7"><input class="form-control" name="xname" value="{$data.xname}" placeholder="姓名-X"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">姓名-Y</label>
								<div class="col-sm-7"><input class="form-control" name="yname" value="{$data.yname}" placeholder="姓名-Y"></div>
							</div>					
							<div class="form-group">
								<label class="col-sm-2 control-label">证件页码</label>
								<div class="col-sm-7"><input class="form-control" name="id_card" value="{$data.id_card}" placeholder="证件页码"></div>
							</div>	
							<div class="form-group">
								<label class="col-sm-2 control-label">证件-X</label>
								<div class="col-sm-7"><input class="form-control" name="xcard" value="{$data.xcard}" placeholder="证件-X"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">证件-Y</label>
								<div class="col-sm-7"><input class="form-control" name="ycard" value="{$data.ycard}" placeholder="证件-Y"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">签署页面</label>
								<div class="col-sm-7"><input class="form-control" name="dpage" value="{$data.dpage}" placeholder="签署页面"></div>
							</div>	
							<div class="form-group">
								<label class="col-sm-2 control-label">签署-X</label>
								<div class="col-sm-7"><input class="form-control" name="dxname" value="{$data.dxname}" placeholder="签署-X"></div>
							</div>	
							<div class="form-group">
								<label class="col-sm-2 control-label">签署-Y</label>
								<div class="col-sm-7"><input class="form-control" name="dyname" value="{$data.dyname}" placeholder="签署-Y"></div>
							</div>								
						</div>
                    </div>
                    <div class="box-footer">
                        <div class="col-sm-2"></div>
                        <div class="col-sm-7">
                            <div class="btn-group pull-right">
                                <button type="submit" class="btn btn-info pull-right submits" data-loading-text="&lt;i class='fa fa-spinner fa-spin '&gt;&lt;/i&gt; {$Think.lang.submit}">{$Think.lang.submit}</button>
                            </div>
                            <div class="btn-group pull-left">
                                <button type="reset" class="btn btn-warning">{$Think.lang.reset}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
</div>
<script type="text/javascript" src="__STATIC__/hry/js/spark-md5.js"></script>
<script type="text/javascript">

$(function(){
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });
    
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $(".select2").select2({language:"zh-CN"});
    
    $('.timepicker').datetimepicker({
        format: 'YYYY-MM-DD HH:mm:ss',   //YYYY-MM-DD HH:mm:ss
        locale: moment.locale('zh-cn')
    });
    
    $("#ck-jumplink").on('ifChecked', function(event){
        $("#jumplink").removeClass("hide");
    });
    $('#ck-jumplink').on('ifUnchecked', function(event){
        $("#jumplink").addClass("hide");
    });
    
    {if condition=" $rest_login == 1 "}
    restlogin('{$rest_login_info}');   //登录超时
    {/if}
})

 $("#file").change(function(){
        var v = $('#file').val();
        var reader = new FileReader();
        reader.readAsDataURL(this.files[0]);
        reader.onload = function(e){
//            console.log(e.target.result);
            $('#file_base64').val(e.target.result);
        };
        calculate();
    });

 function calculate(){
        var fileReader = new FileReader(),
        blobSlice = File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice,
            file = document.getElementById("file").files[0],
            chunkSize = 2097152,
            // read in chunks of 2MB
            chunks = Math.ceil(file.size / chunkSize),
            currentChunk = 0,
            spark = new SparkMD5();

        fileReader.onload = function(e) {
            spark.appendBinary(e.target.result); // append binary string
            currentChunk++;

            if (currentChunk < chunks) {
                loadNext();
            }
            else {
                $('#file_md5').val(spark.end());
                console.log(spark.end());

            }
        };

		function loadNext() {
			var start = currentChunk * chunkSize,
				end = start + chunkSize >= file.size ? file.size : start + chunkSize;

			fileReader.readAsBinaryString(blobSlice.call(file, start, end));
		};
		loadNext();
}
</script>
{/block}